p
  = link_to '新建', new_coupon_path , class: 'btn btn-info btn-xs font-style', remote: true
  input type="button" value="导入" class="modal_link_up btn btn-success btn-xs font-style"
div.show-form
  /= render 'form'
/= paginate @coupons
table.table.table-inverse.table-striped.table-bordered.table-hover
  thead
    tr
      th 名称
      th 价格
      th 数量
      th 开始日期
      th 结束日期
      th 使用地区 
      th 类型
      th 领取数
      th 投放状态
  tbody
    - @coupons.each do |coupon|
      tr
        td 
           = link_to coupon.name, coupons_show_path(params_item(coupon)), class: 'btn btn-info btn-xs'
        td = coupon.price
        td = coupon.number
        td = coupon.begin_date
        td = coupon.end_date
        td = coupon.region
        td = coupon.kind
        td = coupon.receive_count
        - if coupon.state
          td(style="color: #46b8da;") 已投放
        - else
          td(style="color: #4cae4c;") 未投放
         
/table.table.table-inverse.table-striped.table-bordered.table-hover
  /thead
    /tr
      /th ID
      /th 名称
      /th 编码
      /th 价格
      /th 使用对象
      /th 开始日期
      /th 结束日期
      /th 领取状态
      /th 使用地区
      /th 是否地区限制
      /th 投放状态
      /th 类型
  /tbody
    /- @coupons.each do |coupon|
      /tr
        /td = coupon.id
        /td = coupon.name
        /td = coupon.code
        /td = coupon.price
        /td = coupon.purpose
        /td = coupon.begin_date
        /td = coupon.end_date
        /td = coupon.user_id.nil? ? '否' : '是'
        /td = coupon.region
        /td = coupon.limit_state ? '是' : '否'
        /td = coupon.state ? '是' : '否'
        /td = coupon.kind
        
/= paginate @coupons

div class="modal fade" id="dialog-message_up"
  div class="modal-dialog"
    div class="modal-content"
      div class="modal-header"
        <button type="button" class="close" data-dismiss="modal"
           span aria-hidden="true" &times;
           span class="sr-only" Close
      div class="modal-body"
        input id="file" type="file"
        button.btn.btn-info.btn-sm#upload(style="margin-top: 50px")  上传
      div class="modal-footer"
        button type="button" class="btn btn-default" data-dismiss="modal" 关闭
                
  
javascript:
     // Modal Link
    $('.modal_link_up').click(function () {
         $('#dialog-message_up').modal();
    }); 
    
    $('#upload').click(function () {
      var formData = new FormData();
      formData.append('file', $('#file')[0].files[0]);
      $.ajax({
         url: '/coupons/import',
         type: 'POST',
         cache: false,
         data: formData,
         processData: false,
         contentType: false
      }).done(function(res) {
        $('#dialog-message_up').modal('hide');
         console.log(res);
      }).fail(function(res) {});
    })
